package com.tuxing.draa_data.pojo.center;

import java.time.LocalDate;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;

import java.io.Serializable;

import com.google.common.base.Strings;
import com.tuxing.draa_data.dto.CnJournalExcelDto;
import com.tuxing.draa_data.pojo.DraaTemporaryBook;
import com.tuxing.draa_data.pojo.db.Adis20220630;
import com.tuxing.draa_data.pojo.db.Adis20220630001;
import com.tuxing.draa_data.pojo.db.Art20220701;
import com.tuxing.draa_data.pojo.db.Weipu20220629;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * <p>
 * 元数据详情信息表-期刊
 * </p>
 *
 * @author yuanshihang
 * @since 2021-11-18
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class NewDcBibliographyPeriDetail implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 元数据记录号
     */
    @TableId(value = "RECORD_ID", type = IdType.ASSIGN_ID)
    private Long recordId;

    /**
     * 出版日期/创刊日期
     */
    @TableField("PUB_DATE")
    private LocalDate pubDate;

    /**
     * 出版年
     */
    @TableField("PUB_YEAR")
    private String pubYear;

    /**
     * 出版地
     */
    @TableField("PUB_LOC")
    private String pubLoc;

    /**
     * 插画作者
     */
    @TableField("ILLUSTRATOR")
    private String illustrator;

    /**
     * DOI
     */
    @TableField("DOI")
    private String doi;

    /**
     * 是否OA刊
     */
    @TableField("OA")
    private String oa;

    /**
     * 主题
     */
    @TableField("SUBJECT")
    private String subject;

    /**
     * 关键词
     */
    @TableField("KEYWORD")
    private String keyword;

    /**
     * 封面地址
     */
    @TableField("COVER_URL")
    private String coverUrl;

    /**
     * 字数
     */
    @TableField("WORD_COUNT")
    private Long wordCount;

    /**
     * 页数
     */
    @TableField("PAGES")
    private Integer pages;

    /**
     * 出版频率代码
     */
    @TableField("PUB_FREQ_CODE")
    private String pubFreqCode;

    /**
     * 邮发代号
     */
    @TableField("PERI_ASORD_NO")
    private String periAsordNo;

    /**
     * 影响因子
     */
    @TableField("IMPACT_FACTOR")
    private String impactFactor;

    /**
     * 收录范围
     */
    @TableField("CITATION_INDEX")
    private String citationIndex;

    /**
     * 同行评审
     */
    @TableField("PEER_REVIEWED")
    private String peerReviewed;

    /**
     * SNIP指数
     */
    @TableField("SNIP")
    private String snip;

    /**
     * citescore指数
     */
    @TableField("CITE_SCORE")
    private String citeScore;

    /**
     * 中图法分类号
     */
    @TableField("CN_CLASS_NO")
    private String cnClassNo;

    /**
     * 国会分类号（外文）
     */
    @TableField("LC_CLASS_NO")
    private String lcClassNo;

    /**
     * 杜威分类号（外文）
     */
    @TableField("DEYEW_CLASS_NO")
    private String deyewClassNo;

    public void create(Long recordId, DraaTemporaryBook noRepeatOne) {
        this.recordId = recordId;
        this.doi = noRepeatOne.getJournalDoi();
        this.oa = noRepeatOne.getFree();
        this.subject = noRepeatOne.getSubject();
        this.keyword = noRepeatOne.getKeyword();
        this.citationIndex = noRepeatOne.getIncludeRange();
    }

    public void createByCnki(Long recordId, CnJournalExcelDto cnJournalExcelDto) {
        this.recordId = recordId;
        this.pubYear = cnJournalExcelDto.getCreateYear();
        this.pubLoc = cnJournalExcelDto.getAddress();
        this.oa = "0";
        this.coverUrl = cnJournalExcelDto.getCovertUrl();
        this.pubFreqCode = cnJournalExcelDto.getPublishingCycle();
        this.periAsordNo = cnJournalExcelDto.getMailingCode();
        this.impactFactor = cnJournalExcelDto.getCompoundIf();

        String yearRange = cnJournalExcelDto.getYearRange();
        if (!Strings.isNullOrEmpty(yearRange)) {
            String[] split = yearRange.split(";");
            this.citationIndex = String.join(split[0], "-", split[split.length - 1]);
        }
    }

    public void createByWeipu(Long recordId , Weipu20220629 weipu20220629){
        this.recordId = recordId;
        this.periAsordNo = weipu20220629.getPostNumber();
        this.coverUrl = weipu20220629.getUrl();
        this.pubLoc = weipu20220629.getAddress();
        this.oa = "0";

    }

    public void createByAdis(Long recordId , Adis20220630 adis20220630){
        this.recordId = recordId;
        this.coverUrl = adis20220630.getImg();
        this.oa = "0";

    }
    public void createByAdis2(Long recordId , Adis20220630001 adis20220630001){
        this.recordId = recordId;
        this.oa = "0";

    }

    public void create(Long recordId){
        this.recordId = recordId;
        this.oa = "0";

    }
}
